﻿Imports System.Linq

Namespace Aricie.DNN.Modules.LuceneSearch.Filtering


    Friend Class FilterRulesManager
        Implements IFilterRulesManager



        Private AvailableRules As List(Of FilterRule) = New List(Of FilterRule)()
        Private MatchingRule As FilterRule = Nothing

        Public Function Matches(q As Lucene.Net.Search.Query) As Boolean Implements IFilterRulesManager.Matches
            MatchingRule = AvailableRules.FirstOrDefault(Function(f) f.Matches(q))
            Return MatchingRule IsNot Nothing
        End Function

        Public ReadOnly Property Rules As System.Collections.Generic.IEnumerable(Of FilterRule) Implements IFilterRulesManager.Rules
            Get
                Return AvailableRules
            End Get
        End Property

        Friend Sub AddRule(r As FilterRule) Implements IFilterRulesManager.AddRule
            AvailableRules.Add(r)
        End Sub
    End Class
End Namespace
